package com.plan.service.card.impl;

import com.plan.base.entity.Result;
import com.plan.controller.card.request.PointProductPageListReq;
import com.plan.controller.card.response.PointProductListRes;
import com.plan.controller.user.response.UserVO;
import com.plan.dao.service.card.PointProductDaoService;
import com.plan.entity.card.PointProduct;
import com.plan.enums.DelFlagEnum;
import com.plan.service.card.PointProductService;
import com.plan.service.card.TeamService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class PointProductServiceImpl implements PointProductService {
    @Resource
    private TeamService teamService;
    @Resource
    private PointProductDaoService pointProductDaoService;

    @Override
    public Result<Long> add(PointProduct p, UserVO user) {
        p.setCreatorId(user.getId());
        p.setUpdaterId(user.getId());
        p.setDelFlag(DelFlagEnum.NORMAL.getType());
        pointProductDaoService.insert(p);
        return Result.ok(p.getId());
    }

    @Override
    public Result<List<PointProductListRes>> getPageList(PointProductPageListReq req) {
        List<PointProductListRes> list = pointProductDaoService.getPageList(req);
        return Result.ok(list);
    }

    @Override
    public Result<Integer> delete(Long teamId, Long id, UserVO user) {
        int num = pointProductDaoService.delete(teamId, id);
        return Result.ok(num);
    }
}
